package com.xyz.bigcorn.admin.log.service.serviceImpl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xyz.bigcorn.admin.log.entity.LoginRecord;
import com.xyz.bigcorn.admin.log.mapper.LoginRecordMapper;
import com.xyz.bigcorn.admin.log.service.LoginRecordService;
import com.xyz.bigcorn.core.base.service.serviceImpl.BaseServiceImpl;
import com.xyz.bigcorn.core.result.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class LoginRecordServiceImpl  extends BaseServiceImpl<LoginRecord> implements LoginRecordService {
    @Autowired
    private LoginRecordMapper loginRecordMapper;

    @Override
    public boolean add(LoginRecord loginRecord) {
        return loginRecordMapper.insert(loginRecord) > 0;
    }

    @Override
    public PageResult<LoginRecord> list(int pageNum, int pageSize, String startDate, String endDate, String account) {
        Page<LoginRecord> page = new Page<>(pageNum, pageSize);
        List<LoginRecord> records = loginRecordMapper.listFull(page, startDate, endDate, account);
        return new PageResult<>(page.getTotal(), records);
    }
}